package com.example.site.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.util.SaResult;
import com.example.site.entity.Room;
import com.example.site.entity.Type;
import com.example.site.service.RoomService;
import com.example.site.service.TypeService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/api/room")
public class RoomController {
    @Resource
    private RoomService roomService;

    /**
     * @param
     * @return
     * @deprecated 创建房间
     */
    @SaCheckLogin
    @PostMapping("/create")
    public SaResult create(@RequestBody Room room) {
        return roomService.create(room);
    }

    /**
     * @param data
     * @return
     * @deprecated 房间查询
     */
    @SaCheckLogin
    @GetMapping("/list")
    public SaResult list(@RequestParam Map<String, String> data) {
        return roomService.getList(data);
    }

    /**
     * @param data
     * @return
     * @deprecated 房间查询 携带类型信息
     */
    @SaCheckLogin
    @GetMapping("/list-join-type")
    public SaResult listJoinType(@RequestParam Map<String, String> data) {
        return roomService.getListJoinType(data);
    }

    /**
     * @param
     * @return
     * @deprecated 编辑
     */
    @SaCheckLogin
    @PostMapping("/edit")
    public SaResult edit(@RequestBody Room room) {
        return roomService.edit(room);
    }
}
